<?php

/** libraries
 * http://docs.joomla.org/JToolBarHelper
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla view library
jimport('joomla.application.component.view');

class bgViewbg extends JView
{
	// Overwriting JView display method
	function display($tpl = null) 
	{	   
       $model = $this->getModel();
       

        switch(JRequest::getVar('task')){
            case 'edit':
                
               
                break;

            default :
            
                $this->permissions = $model->getAllPermission();
                
                $temp = array();
                foreach($this->permissions as $perm){
                    $perm = (array)$perm;
                    $temp[$perm['PRRM_FUNC_CODE']][$perm['PRRM_GRUM_CODE']]['PRRM_INSERT']  = $perm['PRRM_INSERT'];
                    $temp[$perm['PRRM_FUNC_CODE']][$perm['PRRM_GRUM_CODE']]['PRRM_UPDATE']  = $perm['PRRM_UPDATE'];
                    $temp[$perm['PRRM_FUNC_CODE']][$perm['PRRM_GRUM_CODE']]['PRRM_DELETE']  = $perm['PRRM_DELETE'];
                    $temp[$perm['PRRM_FUNC_CODE']][$perm['PRRM_GRUM_CODE']]['PRRM_EDITOWN'] = $perm['PRRM_EDITOWN'];
                }
                $this->permissions = $temp;
                unset($temp);
                
                // why we use this->fnc because we have functions which isn't exist in table perm
                $this->func = $model->getAllFunc();
                $this->groups = $model->getAllGroupUser();
                
            	JToolBarHelper::title( 'ユーザーロール管理', 'permission' );
                JToolBarHelper::save('save','登録');
            	JToolBarHelper::cancel('cancel', 'キャンセル');
		}
        
		parent::display();
	}
}




